#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/4/20 22:11
# @Author : 闫峰
# @File    : common_func.py
import time

from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database


def get_timestamp():
    return int(time.time())
test_zhcxkj_center_promotion = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"), "test_jdw_database")

def get_access_token(ordersourceid):
    sql1 = """	SELECT user_token_secret_access_key  
    FROM test_zhcxkj_center_data.rb_order_source_ebay_amazon_api 
    WHERE customer_id=1 AND order_source_id=%s;"""
    res1 = test_zhcxkj_center_promotion.fetch_all(sql1, (ordersourceid,))
    access_token = res1[0]["user_token_secret_access_key"]
    return access_token


def get_shop_id(ordersourceid):
    sql1 = """	
    SELECT cert_idaccess_key_id  
    FROM test_zhcxkj_center_data.rb_order_source_ebay_amazon_api  
    WHERE customer_id=1 AND order_source_id=%s;"""
    res1 = test_zhcxkj_center_promotion.fetch_all(sql1, (ordersourceid,))
    shop_id = res1[0]["cert_idaccess_key_id"]
    return shop_id